package com.symphony.serialization;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.json.JSONObject;

public class Program {
	public static void main(String[] args) {
		String path = "d://json.txt";
		
//		Map<String, List<Report>> reportsForJson = new HashMap<String, List<Report>>();
//		List<Report> l1 = new ArrayList<Report>();
//		l1.add(new Report(1));
//		l1.add(new Report(1));
//		l1.add(new Report(1));
//		
//		List<Report> l2 = new ArrayList<Report>();
//		l2.add(new Report(2));
//		l2.add(new Report(2));
//		l2.add(new Report(2));
//		
//		reportsForJson.put("event1", l1);
//		reportsForJson.put("event2", l2);
//		
//		JSONObject newJson = Serializer.createReportsJsonFromMap(reportsForJson);
//		System.out.println(newJson.toString());
//		Serializer.writeJsonToFile(path, newJson);
//		
//		System.out.println();
		
		JSONObject eventsJson = Serializer.readJsonFromFile(path);
		Map<String, List<Report>> reportsMapFromJson = Serializer.createEventsMapFromJsonObject(eventsJson);
		Set<Entry<String, List<Report>>> entries = reportsMapFromJson.entrySet();
		Iterator<Entry<String, List<Report>>> i = entries.iterator();
		while (i.hasNext()) {
			Entry<String, List<Report>> currEntry = i.next();
			System.out.println("Event: " + currEntry.getKey() + " ; Reports: " + currEntry.getValue().toString());
		}
		
	}
	
	
}
